<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtmBox">
<head>
<include file="./Public/common/meta.html" />
<style type="text/css">
<!--
*{margin:0;padding:0;}
.box{margin-bottom:12px;overflow-x:hidden;overflow-y:hidden;padding:3px;background:#FFFFEE;border:solid 1px #999;}
 -->
</style>
</head>

<body>

	<div class="xsWrap">
		<!-- 顶导 -->
		<include file='./Public/common/header.html' />
		<!-- /顶导 -->
		<!-- main -->
		<div class="mainBox clearfix">
			<div class="xsNLayout">
				<!-- 博文 -->			
				<div class="blogLayBox clearfix">
					<div class="viewBlogBox">
						<div class="xsTit clearfix">
							<!-- 博主权限 -->
							<if condition="$is_my_post">
							<a class="btnF blogEdiBtn" href="__ROOT__/post/edit/{$post.id}">编辑</a>	
							</if>
							<!-- /博主权限 -->						
							<h3 class="viewBlogTit">{$post.title}<span class="vBlogDate">({$post.create_date})</span></h3>

						</div>
						<div class="viewBlogSo clearfix">
							<p class="vBlogSort">所属专辑：{$album_name}</p>
							<!-- <if condition="$is_my_post">
							<p class="titShareBox"><span class="shareTxt">分享：</span><a class="shareBtn"><span class="shareIcon icon_weibo"></span></a><a class="shareBtn"><span class="shareIcon icon_qzone"></span></a><a class="shareBtn"><span class="shareIcon icon_weixin"></span></a></p>
							</if> -->
						</div>							
						
						<div class="viewblogwrap">
							<div class="viewblogTxt clearfix">
							<!-- 博客正文 -->
							<p style="text-indent:2em;">{$post.content|htmlspecialchars_decode}</p>

							<!-- /博客正文 -->
							</div>
							<p class="blogComUrl">来源：{$post.post_link}</p>							
						</div>
						<br><br>
						<div class="formCata" style="border-bottom:0;">
                            
                            <dl class="clearfix">
                                <dt class="formName blogComUrl">评论：</dt>
                                <dd class="formInput">
                                    <textarea class="xsArea fwA01" name="comment" style="width:100%;" placeholder="至少4个字符的评论"></textarea>
                                </dd>
                                <!-- <dd class="formTip">
                                    <span class="xsIcon icon_wrong"></span>请选择分类</dd>-->
                              </dl> 
                              <dl class="formTip commentTip" style="margin-top:5px;display:none;">
									<span class="xsIcon icon_wrong"></span>至少4个字符的评论
								</dl>

                              <dl class="clearfix" style="margin-top:2px;">                              
                                <dd class="formInput">
                                	<if condition="session('__user__') neq null">
                                    <a class="btnE" href="javascript:comment_post({$post.id});">发表评论</a>
                                    <else/>
                                    <a class="btnE" href="##">请先登录或注册</a>
                                    </if>
                                </dd>
                            </dl>

                        </div>
                       

						<div class="viewBlogComBox">
							<div class="xsTit">
								<p class="viewBlogTit">评论</p>
							</div>
							<div class="vewComWrap">
								<ul class="vewComList">
									<foreach name="comment_list" item="vo">
									<li class="clearfix">
										<div class="noUserImg"><a class="userPic" href="#">
										<img src="__PUBLIC__/{:W('My/getUserVal',array($vo['user_id'],'header_img'))}" alt="" class="userImg" width="60" height="60"></a></div>
										<div class="notiDetail">
											<div class="notiFBox">
												<p class="notiUser"><a class="notiName" href="#">
												{:W('My/getUserVal',array($vo['user_id'],'aliasname'))}</a>
												<span class="notiDate">{$vo.create_date}</span></p>
												<if condition="session('__user__') neq null">
												<p class="notiR"> <a class="notiRly" onclick="open_reply({$vo.id})">回复</a><a class="notiRly" onclick="_report({$vo.user_id})">举报</a></p>
												</if>
											</div>
                                            {:W('My/commentBuilder',array($vo['parent_id']))}
											<p class="notiCon clearfix">{$vo.content}</p>
										</div>

									</li>
									</foreach>
									

								</ul>

							</div>

						</div>
						
					</div>

					<div class="viewBlogR">
						<div class="viewRBox">
							<p class="viewRTit">本专辑其他博文</p>
						</div>
						<div class="viewRBlog">
						<ul class="viewRList">
						   <foreach name="post_others" item="vo">
							<li><a class="rListTxt" href="__ROOT__/post/{$vo.id}">{$vo.title}</a></li>
							</foreach>
												
						</ul>
						<p class="viewRMore"><a href="__ROOT__/album/{$post.album_id}">更多>></a></p>
						</div>
					</div>

				</div>
				<!-- /博文 -->
			</div>
		</div>

		<!-- /main -->

	</div>

	<!-- 弹层 -->
    <include file="./Public/common/openWindows.html" />

     <div id="replyComment" class="xsRegLayer" style="display:none; top:200px; left:400px;z-index:9999">
        <a class="closeBtn">
            <span class="xsIcon icon_close"></span>
        </a>
        <p class="logoBox">
            <span class="logoImg logoL"></span>
        </p>
        <p class="regWay">回复</p>
        <div class="LayRegWrap">
            <div class="LayRegBox" style="width: 350px;">
            	<input type="hidden" id="comment_id_val" />
                <p class="logInput logName">
                    <textarea id="replyContent" class="xsArea fwA01"></textarea>
                </p>            
            </div>
            <p class="LaylogBtn"><a class="logBtn" href="javascript:reply_comment();" >回复</a>
            </p>
        </div>       
    </div>
    <!-- 弹层） -->
	<script type="text/javascript">
    (function($) {
    	var page_no=2;
    	var post_id ='{$post.id}';
    	var $window = $(window),
            $document = $(document);

		/**
         *scroll 事件
         */
        function onScroll() {
            // Check if we're within 100 pixels of the bottom edge of the broser window.
            var winHeight = window.innerHeight ? window.innerHeight : $window.height(), // iphone fix
                closeToBottom = ($window.scrollTop() + winHeight > $document.height() - 100);
            if (closeToBottom) {
                //AJAX载入的数据
                $.ajax({
                    url: "__ROOT__/post/wookmarkAjax",
                    dataType: "html",
                    data:{
                    	'page_no':page_no,
                    	'post_id':post_id
                    },
                    success: function(html) {                  	
                    	if(html!=null&&html!=""){
                    		page_no++;
                    		//把新数据追加到ul
                       		 $(".vewComList").append(html);                        	
                    	}
                        
                    }
                });
                
            }
        };

		$window.bind('scroll', onScroll);

    })(jQuery);
    function comment_post(post_id){
    	var comment = $("textarea[name=comment]").val();
    	if(comment==null||comment==""||comment.length<4){
    		$(".commentTip").show();
    		return;
    	}
    	$.post("__ROOT__/post/comment",{
    		post_id:post_id,
    		content:comment
    	},function(html){
    		alert("发表评论成功！");
    		$("textarea[name=comment]").val("");
    		$(".vewComList").append(html);  
    	});
    }

    function _report(user_id){
    	$.post("__ROOT__/post/reportUser",{
    		user_id:user_id
    	},function(data){
    		if(data=="success"){
    			alert("举报成功！");
    		}
    	
    	});
    }

    function open_reply(comment_id){
    	$("#comment_id_val").val(comment_id);
    	$(".mask").show();
    	$("#replyComment").show();
    	
    }

    function reply_comment(){
    	var comment_id = $("#comment_id_val").val();
    	var post_id ='{$post.id}';
    	var replyContent = $("#replyContent").val();
    	$.post("__ROOT__/post/replyComment",{
    		comment_id:comment_id,
    		post_id:post_id,
    		content:replyContent
    	},function(data){
    		alert("发表评论成功！");
            $(".mask").hide();
            $("#replyComment").hide();
    		$("comment_id_val").val("");
    		$("#replyContent").val("");            
    		$(".vewComList").append(data);  
    	},"html");
    }
    </script>

</body>
</html>
